package cn.tedu.egmvc3.base.config.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;




    public JsonResult(StatusCode statusCode){
        this.state = statusCode.getState();
        this.message = statusCode.getMessage();
    }
    ////构造函数：接收StatusCode对象和Object类型的数据，初始化state、message和data。
    public JsonResult(StatusCode statusCode, Object data){
        this.state = statusCode.getState();
        this.message = statusCode.getMessage();
        this.data = data;
    }

   //静态方法：有具体数据返回的
    public static JsonResult ok(Object data){

        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }

    //没有具体数据返回的
    public static JsonResult ok(){
        //return new JsonResult(StatusCode.OPERATION_SUCCESS);
        return ok(null);
    }

}
